﻿using System.Configuration;
using System.Data;
using System.Diagnostics;
using System.Globalization;
using System.Windows;
using TMI85303.UI.View;
using TMI85303.Utils;

namespace TMI85303
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : Application
    {
        //private void Application_LoadCompleted(object sender, System.Windows.Navigation.NavigationEventArgs e)
        //{

        //    base.OnLoadCompleted(e);
        //    List<ResourceDictionary> dictionaryList = new List<ResourceDictionary>();
        //    foreach (ResourceDictionary dictionary in Application.Current.Resources.MergedDictionaries)
        //    {
        //        dictionaryList.Add(dictionary);
        //    }
        //    var targetLanguage = ConfigurationManager.AppSettings["Language"];

        //    if (targetLanguage == null)
        //        targetLanguage = "en-us";

        //    string requestedCulture = @"Resources\Languages\" + targetLanguage + ".xaml";
        //    var resourceDictionary = dictionaryList.FirstOrDefault(d => d.Source.OriginalString.Equals(requestedCulture));

        //    if (resourceDictionary != null)
        //    {
        //        Application.Current.Resources.MergedDictionaries.Remove(resourceDictionary);
        //        Application.Current.Resources.MergedDictionaries.Add(resourceDictionary);
        //    }
        //    else
        //    {
        //        MessageBox.Show("Can not find the language resources.");
        //        return;
        //    }
        //}
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            var targetLanguage = ConfigurationManager.AppSettings["Language"];

            LanguageManager.Instance.ChangeLang(new CultureInfo(targetLanguage ?? Lang.Chinese));

            GlobalApp.BuildTime = System.IO.File.GetLastWriteTime(this.GetType().Assembly.Location);

   
        }
}

}
